package com.thinkingcoder.tccache.core.command.list;

import static com.thinkingcoder.tccache.constant.CommandConstants.ListCmd.LPUSH;

import com.thinkingcoder.tccache.core.command.Command;
import com.thinkingcoder.tccache.core.model.Reply;
import com.thinkingcoder.tccache.core.TcCache;

/**
 * LPUSH command.
 */
public class LPushCmd implements Command {
    @Override
    public String name() {
        return LPUSH;
    }

    @Override
    public Reply<?> exec(TcCache cache, String[] args) {
        String key = getKey(args);
        String[] vals = getParamsNoKey(args);
        return Reply.integer(cache.lPush(key, vals));
    }
}
